/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package cn.icanci.design.structure.decoratorpattern;

/**
 * 抽象装饰器Class继承组件，并且实现其方法 装饰器持有组件方法
 * - 创建具体的组件实现
 * - 创建装饰器实现，将组件实现传入
 * - 执行装饰器的方法
 *
 * 装饰器模式和代理模式很类似(静态代理)
 * 不过静态代理如果需要拓展的话，就必须创建不同的代理对象，在代理对象中进行调用
 * 而装饰器模式如果拓展的话，是拓展的装饰类
 *
 * 装饰器模式和代理模式的最大区别就是功能区别
 * - 代理是做增强
 * - 装饰器模式做拓展
 * - 感觉就是个概念的设计划分
 *
 * @author icanci
 * @date Created in 2021/07/17 09:50
 * @version 1.0
 */
public class DecoratorClient {
    public static void main(String[] args) {
        TargetComponent targetComponent = new TargetComponent();

        Decorator t1 = new Target1Decorator(targetComponent);
        Decorator t2 = new Target2Decorator(targetComponent);

        System.out.println(" ------------------------------------------------------------------------");
        t1.operation();
        System.out.println(" ------------------------------------------------------------------------");
        t2.operation();
    }
}
